package com.fesine.learn.service.impl;

import com.fesine.learn.dao.UserInfoMapper;
import com.fesine.learn.po.UserInfoPo;
import com.fesine.learn.service.UserInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by Administrator on 2017/4/15.
 */
@Service("userInfoService")
public class UserInfoServiceImpl implements UserInfoService {

    @Resource
    private UserInfoMapper userInfoMapper;


    @Override
    public int addUserInfo(UserInfoPo userInfoPo) {
        return userInfoMapper.insert(userInfoPo);
    }

    @Override
    public int modifyUserInfo(UserInfoPo userInfoPo) {
        return userInfoMapper.update(userInfoPo);
    }

    @Override
    public int deleteUserInfo(UserInfoPo userInfoPo) {
        return userInfoMapper.delete(userInfoPo);
    }

    @Override
    public void deleteUsers(String[] ids) {
        UserInfoPo userInfoPo;
        for (String id : ids) {
            userInfoPo = new UserInfoPo();
            userInfoPo.setId(id);
            this.deleteUserInfo(userInfoPo);
        }
    }

    @Override
    public UserInfoPo getUserInfo(UserInfoPo userInfoPo) {
        return userInfoMapper.selectOne(userInfoPo);
    }

    @Override
    public List<UserInfoPo> listUserInfo(UserInfoPo userInfoPo) {
        return userInfoMapper.selectList(userInfoPo);
    }

    @Override
    public int getTotal(UserInfoPo userInfoPo) {
        return userInfoMapper.count(userInfoPo);
    }
}
